package com.sephiron.clocksynchronizer;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

public class SetTimeNDateWithPictureConfirmFragment extends DialogFragment {
    public static final String TAG = "SetTimeNDateWithPictureConfirmFragment";

    public static SetTimeNDateWithPictureConfirmFragment newInstance() {
        SetTimeNDateWithPictureConfirmFragment fragment = new SetTimeNDateWithPictureConfirmFragment();
        return fragment;
    }

    private void sendResult(int resultCode) {
        if (getTargetFragment() == null) {
            return;
        }
        getTargetFragment().onActivityResult(getTargetRequestCode(),
                resultCode, new Intent());
    }


    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
//        View v = getActivity().getLayoutInflater().inflate(
//                R.layout.dialog_set_real_time_with_picture_time, null);

        return new AlertDialog.Builder(getActivity())
//                .setView(v)
                .setTitle(R.string.setTimeWithPictureTime)
                .setMessage(R.string.setRealTimeWithPictureTimeQuestion)
                .setPositiveButton(R.string.setRealTimeWithPictureTimeNewPicture,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                                int which) {
                                sendResult(Activity.RESULT_OK);
                            }
                        })
                .setNeutralButton(R.string.setRealTimeWithPictureTimePickPicture,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                                int which) {
                                sendResult(Activity.RESULT_FIRST_USER);
                            }
                        })
                .setNegativeButton(android.R.string.cancel,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                                int which) {
                                sendResult(Activity.RESULT_CANCELED);
                            }
                        })

                .create();
    }



}
